<!--
 * @Author: wangjian
 * 656876071@qq.com
 * @Date: 2024-08-08 16:48:34
 * @LastEditTime: 2024-08-12 16:27:06
 * @FilePath: src/views/sys/dict/DictOptionForm.vue
 * @Description: 
 -->
<script setup lang="ts">
import {useDictOptionForm} from './DictHooks'
import {SIMPLE_FORM_SUBMIT_KEY} from "@/core/common/hooks/FormHooks";
import {useRoute} from "vue-router";
const callback = defineEmits([SIMPLE_FORM_SUBMIT_KEY])
const {
  form,
  modalIsVisible,
  modalIsSubmitting,
  modalSubmit,
  showEditForm,
  showAddForm
} = useDictOptionForm(callback)
const route = useRoute()
const customShowAddForm = () => {
  showAddForm()
  form.value.dictId =  route.params.dictId as string
}
const customShowEditForm = (id:string) => {
  showEditForm(id)
  form.value.dictId = route.params.dictId as string
}
defineExpose({
  customShowAddForm,
  customShowEditForm
})
</script>

<template>
  <a-modal v-model:open="modalIsVisible" title="字典目录维护" width="30rem" :maskClosable="false">
    <template #footer>
      <a-button key="back" @click="modalIsVisible = false">取消</a-button>
      <a-button :loading="modalIsSubmitting" key="submit" type="primary" @click="modalSubmit">录入</a-button>
    </template>
    <a-form :disabled="modalIsSubmitting" :label-col="{span:5}" :wrapper-col="{span: 18}" label-align="right">
      <a-form-item label="名称">
        <a-input v-model:value="form.label" placeholder="请输入名称"/>
      </a-form-item>
      <a-form-item label="值">
        <a-input v-model:value="form.val" placeholder="请输入值"/>
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<style scoped>

</style>